package cn.wolfcode.controller;

import cn.wolfcode.domain.Department;
import cn.wolfcode.query.JsonResult;
import cn.wolfcode.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/jso")
public class JsonController {
    @RequestMapping("/getTime")
    @ResponseBody
    public JsonResult getTime(){
        Date now = new Date();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setSuccess(true);
        jsonResult.setMsg(now.toLocaleString());
        return jsonResult;
    }
    @Autowired
    private IDepartmentService departmentService;
    @RequestMapping("/j1")
    @ResponseBody
    public List<Department> getDepartemnt(){
        List<Department> list = departmentService.selectAll();
        return list;
    }
}
